package com.shortvedio.content.api;


import com.shortvedio.base.context.BaseContext;
import com.shortvedio.base.model.Result;
import com.shortvedio.content.service.CommentsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/comments")
//评论查看和上传相关的接口
public class CommentsController {
    @Autowired
    CommentsService commentsService;

    @PostMapping("/addRootComment")  //添加根评论
    public Result addRootComment(@RequestParam Long videoId, @RequestParam String content) {
        Long userId = BaseContext.getCurrentId();
        Result result = commentsService.addRootComment(videoId, userId, content);
        return result;
    }

    @PostMapping("/addReplyComment")   //添加回复评论
    public Result addReplyComment(@RequestParam Long parentId, @RequestParam Long videoId, @RequestParam String content, @RequestParam Long commentObject) {
        Long userId = BaseContext.getCurrentId();
        Result result = commentsService.addReplyComment(parentId, videoId, userId, content, commentObject);
        return result;
    }

    @DeleteMapping("/delete_comment")   //删除评论
    public Result deleteComment(@RequestParam Long commentId){
        Long userId = BaseContext.getCurrentId();
        Result result = commentsService.deleteComment(commentId, userId);
        return result;
    }

}
